<template>
  <ion-page>
    <ion-header class="ion-no-border">
      <ion-toolbar>
        <ion-buttons slot="start">
          <ion-back-button color="dark" text=""></ion-back-button>
        </ion-buttons>
        <ion-title>我的借阅</ion-title>
      </ion-toolbar>
    </ion-header>
    <ion-content :fullscreen="true">
      <ion-row class="row1 border_bottom" :key="index" v-for="(item,index) of tableData">
        <ion-col class="col1" size="9">
          <img :src="require('../../public/assets/images/1.jpg')">
          <div class="d-f f-d-c ion-justify-content-around">
            <div class="div4">{{ item.bookname }}</div>
            <div class="div5">借阅日期：{{ item.borrowdate }}</div>
            <div class="div6" v-if="item.realityreturndate!==''">归还日期：{{ item.realityreturndate }}</div>
          </div>
        </ion-col>
        <ion-col class="col1 ion-align-items-center" style="font-size: small;">
          <span v-if="item.realityreturndate!==''" style="color: #28ba62">已归还</span>
          <span id="wgh" v-if="item.realityreturndate===''" style="color: orangered">未归还</span>
          <ion-popover trigger="wgh" side="left" alignment="start">
            <ion-content class="ion-padding">计划归还日期：{{item.planreturndate}}</ion-content>
          </ion-popover>
        </ion-col>
      </ion-row>
    </ion-content>
  </ion-page>
</template>

<script lang="ts">
import {postAction} from '@/api/manage';
import { defineComponent } from 'vue';
import {
  IonHeader,
  IonFooter,
  IonToolbar,
  IonTitle,
  IonInput,
  IonPage,
  IonCard,
  IonItem,
  IonIcon,
  IonButton,
  IonCardContent,
  IonContent,
  IonSearchbar,
  IonCardHeader,
  IonRow,
  IonCol,
  IonSegment,
  IonSegmentButton,
  IonLabel,
  IonAvatar,
  IonImg,
  IonBackButton,
  IonButtons,
  IonListHeader,
  IonChip,
  IonPopover
} from '@ionic/vue';
import {callOutline, reorderFourOutline, lockClosedOutline, personOutline} from 'ionicons/icons';
export default defineComponent({
  name: 'BorrowPage',
  components: {
    IonHeader,
    IonFooter,
    IonToolbar,
    IonTitle,
    IonInput,
    IonPage,
    IonCard,
    IonItem,
    IonIcon,
    IonButton,
    IonCardContent,
    IonContent,
    IonSearchbar,
    IonCardHeader,
    IonRow,
    IonCol,
    IonSegment,
    IonSegmentButton,
    IonLabel,
    IonAvatar,
    IonImg,
    IonBackButton,
    IonButtons,
    IonListHeader,
    IonChip,
    IonPopover
  },
  mounted(){
    this.getBorrowList({currentPage:0,sizePerPage:this.pageObj.pageSize})
  },
  data() {
    return {
      pageObj: {
        total:0,
        pagerCount: 0,
        pageSize:8,
        currentPage:0
      },
      tableData: [],
    }
  },
  methods:{
    getBorrowList(obj:any) {
      postAction('borrow/list', obj).then((res:any) => {
        this.pageObj.total=res.data.total;
        this.pageObj.pagerCount=res.data.totalPages;
        this.tableData=res.data.list
        console.log(this.tableData)
      });
    },
    /*postAction(url:string,parameter:any){
      const service = axios.create({
        baseURL: '/service', // api base_url
        timeout: 90000 // 请求超时时间
      })
      return service({
        url: url,
        method:'post' ,
        data: parameter
      })
    }*/
  },
  setup() {
    return {
      lockClosedOutline,
      callOutline,
      reorderFourOutline,
    }
  }
});
</script>

<style lang="less" scoped>
.row1{
  margin-top: 10px;
  margin-left: 16px;
  .col1{
    display: flex;
    img{
      width: 80px;
      height: 100px;
    }
    .div1{
      display: flex;
    }
    .div2{
      color: red;
      font-size: smaller;
      margin-right: 5px
    }
    .div4{
      font-size: medium;
    }
    .div5{
      font-size: x-small;
      color: #8c8c8c;
    }
    .div6{
      font-size: x-small;
      color: #28ba62;
    }
  }
}
ion-toolbar{
  --background: #fff;
}
</style>
